$(function () {
    $.ajax({
        url: "/vote/showAll",
        type: "post",
        data: "",
        dataType: "json",
        success: function (data) {
            var str = "<table>" + "<tr style='background:aqua'>" +
                "<th>序号</th>" +
                "<th>主题</th>" +
                "<th>投票/查看</th>" +
                "<th>创建时间</th>" +
                "</tr>";
            $.each(data, function (i) {
                str += ((i % 2 == 0) ? "<tr>" : "<tr style='background: aquamarine'>") +
                    "<td>" + (i + 1) + "</td>" +
                    "<td><a href='vote.html?id=" + this.id + "'>" + this.title + "</a> </td>" +
                    "<td>" + this.totalVotes + "/" + this.viewTimes + "</td>" +
                    "<td>" + this.createDate + "</td>" +
                    "</tr>";
            })
            str += "</table>";
            $("#show").html(str);
        }
    })
})